/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test1.library.command;

import java.io.*;

/**
 *
 * @author admin
 */
public class delete implements ICommand {
    private static final String DELETE = "Удаление";
	
	private static final String INFO = "Удаляет книгу из библиотеки";
	
	public String name() {
		return DELETE;
	}

	
	public String info() {
		return INFO;
	}
    public void delete() throws UnsupportedEncodingException, IOException {
      System.out.println("Введите автора книги");
        BufferedReader d = new BufferedReader(new InputStreamReader(System.in, "windows-1251"));
String author = d.readLine();
 System.out.println("Введите название книги");
        BufferedReader k = new BufferedReader(new InputStreamReader(System.in, "windows-1251"));
String Name = k.readLine();
String book = author + " - "+ Name;
        String list[] = new File("books").list();
        int kk=0;
            for(int i = 0; i < list.length; i++)
                if(book.equals(list[i])){
                    kk=1;
                    System.out.println("Идет поиск книги");
                    System.out.println("Книга найдена!");
                     File file = new File("books\\"+book);
                     file. delete();
                     System.out.println("Книга удалена!");         
                       break; } 
                       if(kk==0)  
                       System.out.println("Искомая книга отсутствует");
    
}
    @Override
    public void execute(String... args) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    }